﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL.Model.Repositories;
using BLL.Utils;

namespace BLL.Model.Voucher
{
    public abstract class Contra : Record
    {
        protected const string BankToCash = "bank to cash";
        protected const string CashToBank = "cash to bank";

        // ContraType can be "Bank to cash" or "Cash to bank"
        private string _contraType;

        protected Contra(IRecordRepository recordRepository) : base(recordRepository)
        {
        }

        public string ContraType
        {
            get { return _contraType; }
            set
            {
                if (new[] { BankToCash, CashToBank }.Contains(value.ToLower()))
                    _contraType = value.ToLower();
                else
                    throw new Exception("Invalid ContraType. ContraType can only be \"" + BankToCash + "\" or \"" + CashToBank + "\"");
            }
        }

        public override string VoucherTypeKey
        {
            get { return Constants.ContraVoucherShortKey; }
        }

        public double Amount;


        protected Exception ContraTypeNull()
        {
            return new Exception("ContraType can not be null for contra voucher.");
        }
    }
}

